/*
 +----------------------------------------------------------------------
 + Title        : user
 + Author       : huwl
 + Version      : 1.0.0
 + Initial-Time : 2023-08-10
 + Last-time    : 这个文件最后修改的时间 + 修改人的名称
 + Desc         : 用户接口
 +----------------------------------------------------------------------
*/

import type { ChangePasswordParams, EditUserParams, EmailForgotPasswordParams, LoginParams, LoginResult, MobileForgotPasswordParams, RegisterParams, SearchUserParams, SearchUserResult } from '@/types/user'
import {http} from '@/utils/httpRequest'

/**
 * 密码登录,请求方式[POST]
 * 
 * @param LoginParams data ---------------------------------必传,参数
 * @returns LoginResult
 * @author huwl
 */
export const reqLoginAPI = (data: LoginParams) => {
    return http<LoginResult>({
        method: 'POST',
        url: 'user/login',
        data
    })
}

/**
 * 短信登录,请求方式[POST]
 * 
 * @param LoginParams data ---------------------------------必传,参数
 * @returns LoginResult
 * @author huwl
 */
export const reqMobileLoginAPI = (data: LoginParams) => {
    return http<LoginResult>({
        method: 'POST',
        url: 'user/mobileLogin',
        data
    })
}

/**
 * 注册,请求方式[POST]
 * 
 * @param RegisterParams data ------------------------------必传,参数
 * @returns any
 * @author huwl
 */
export const reqRegisterAPI = (data: RegisterParams) => {
    return http({
        method: 'POST',
        url: 'user/register',
        data
    })
}

/**
 * 编辑用户,请求方式[POST]
 * 
 * @param EditUserParams data ------------------------------必传,参数
 * @returns any
 * @author huwl
 */
export const reqEditUserAPI = (data: EditUserParams) => {
    return http({
        method: 'POST',
        url: 'user/edit',
        data
    })
}

/**
 * 修改手机号,请求方式[POST]
 * 
 * @param string mobile ------------------------------------必传,手机号
 * @returns any
 * @author huwl
 */
export const reqEditMobileAPI = (mobile: string) => {
    return http({
        method: 'POST',
        url: 'user/editMobile',
        data: {mobile}
    })
}

/**
 * 修改邮箱,请求方式[POST]
 * 
 * @param string email -------------------------------------必传,邮箱
 * @returns any
 * @author huwl
 */
export const reqEditEmailAPI = (email: string) => {
    return http({
        method: 'POST',
        url: 'user/editEmail',
        data: {email}
    })
}

/**
 * 修改密码,请求方式[POST]
 * 
 * @param ChangePasswordParams data ------------------------必传,参数
 * @returns any
 * @author huwl
 */
export const reqChangePasswordAPI = (data: ChangePasswordParams) => {
    return http({
        method: 'POST',
        url: 'user/changePassword',
        data
    })
}

/**
 * 登录发送验证码,请求方式[POST]
 * 
 * @param string mobile ------------------------------------必传,手机号
 * @returns any
 * @author huwl
 */
export const reqLoginSendCodeAPI = (mobile: string) => {
    return http({
        method: 'POST',
        url: 'user/loginSendCode',
        data: {mobile}
    })
}

/**
 * 使用微信绑定的手机号登录,请求方式[POST]
 * 
 * @param string code --------------------------------------必传,动态令牌
 * @returns any
 * @author huwl
 */
export const reqWxMobileLoginAPI = (code: string) => {
    return http({
        method: 'POST',
        url: 'user/wxMobileLogin',
        data: {code}
    })
}

/**
 * 手机找回密码发送验证码,请求方式[POST]
 * 
 * @param string mobile ------------------------------------必传,手机号
 * @returns any
 * @author huwl
 */
export const reqMobileForgotSendCodeAPI = (mobile: string) => {
    return http({
        method: 'POST',
        url: 'user/mobileForgotPasswordSendCode',
        data: {mobile}
    })
}

/**
 * 邮箱找回密码发送验证码,请求方式[POST]
 * 
 * @param string email -------------------------------------必传,邮箱
 * @returns any
 * @author huwl
 */
export const reqEmailForgotSendCodeAPI = (email: string) => {
    return http({
        method: 'POST',
        url: 'user/emailForgotPasswordSendCode',
        data: {email}
    })
}

/**
 * 手机找回密码,请求方式[POST]
 * 
 * @param MobileForgotPasswordParams data ------------------必传,参数
 * @returns any
 * @author huwl
 */
export const reqMobileForgotPasswordAPI = (data: MobileForgotPasswordParams) => {
    return http({
        method: 'POST',
        url: 'user/mobileForgotPassword',
        data
    })
}

/**
 * 邮箱找回密码,请求方式[POST]
 * 
 * @param EmailForgotPasswordParams data -------------------必传,参数
 * @return any
 * @author huwl
 */
export const reqEmailForgotPasswordAPI = (data: EmailForgotPasswordParams) => {
    return http({
        method: 'POST',
        url: 'user/emailForgotPassword',
        data
    })
}

/**
 * 刷新token,请求方式[POST]
 * 
 * @param string refresh_token -----------------------------必传,刷新token
 * @returns any
 * @author huwl
 */
export const reqRefreshTokenAPI = (refresh_token:string) => {
    return http({
        method: 'POST',
        url: 'user/refreshToken',
        data: {refresh_token}
    })
}

/**
 * 用户列表,请求方式[GET]
 * 
 * @param SearchUserParams data ----------------------------非必传,参数
 * @returns SearchUserResult
 * @author huwl
 */
export const reqUserListAPI = (data?: SearchUserParams) => {
    return http<SearchUserResult>({
        method: 'GET',
        url: 'user/list',
        data
    })
}

/**
 * 用户信息,请求方式[GET]
 * 
 * @param string uid ---------------------------------------必传,用户Id
 * @returns any
 * @author huwl
 */
export const reqUserInfoAPI = (uid: string) => {
    return http({
        method: 'GET',
        url: 'user/detail',
        data: {uid}
    })
}